Reproduce #624 race condition via real server crash#626
Conversation
…as strict xfail why: The previous test looped new_session() 10 times hoping to trigger a timing race, but the bug is deterministic in PyInstaller + Python 3.13 + Docker environments (LD_LIBRARY_PATH contamination crashes tmux server after new-session returns, causing list-sessions to miss the session). what: - Replace loop-based test with monkeypatch that intercepts neo.fetch_objs - Return empty list on first list-sessions call, simulating stale response - Add strict=True so XPASS signals when retry-based fix is added - Keep real tmux new-session execution to validate integration - Add precise type annotations matching neo.fetch_objs signature
why: Previous test monkeypatched fetch_objs to return [], bypassing all real tmux interaction. This version exercises the full code path with real tmux commands — only crash timing is controlled. what: - Kill real tmux server inside fetch_objs wrapper, start replacement - Bumper session ensures session_id mismatch (original $1 vs replacement $0) - All 7 code paths exercised: new-session, kill-server, replacement new-session, list-sessions, fetch_objs parsing, fetch_obj search, TmuxObjectDoesNotExist
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #626 +/- ##
==========================================
+ Coverage 45.39% 45.48% +0.08%
==========================================
Files 22 22
Lines 2249 2249
Branches 360 360
==========================================
+ Hits 1021 1023 +2
+ Misses 1082 1081 -1
+ Partials 146 145 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Closing — the race condition this PR reproduces no longer exists. This PR (Mar 2026) demonstrates a server-crash race in That race was fixed in #625 (released in v0.53.1, see CHANGES under As a result, the PR's test patch on If you want to keep documenting this scenario for regression coverage, the test could be adapted to assert on the new code path's behavior under server crash (e.g. patching Confirmed during a 2026-04-26 batch rebase audit. |
Summary
test_new_session_race_conditionthat reproduces Race condition in new_session() in some environments (e.g. PyInstaller + Python 3.13+ + Docker) #624 by injecting a real tmux server crash betweennew-sessionandlist-sessionsstrict=Truexfail: will flip to XPASS when retry logic is added (the fix)Related:
How it works
race_testgets$1server.new_session("race_test")runs realtmux new-session→ returns$1fetch_objsintercepts the firstlist-sessionscall: kills the server, starts a replacement (which gets$0)fetch_objsrunslist-sessionsagainst the replacement server — finds only$0fetch_objsearches for$1, doesn't find it →TmuxObjectDoesNotExistTest plan
uv run pytest tests/test_server.py::test_new_session_race_condition -xvs→ XFAILuv run ruff check tests/test_server.py→ cleanuv run mypy tests/test_server.py→ cleanuv run pytest tests/test_server.py -v→ 29 passed, 1 skipped, 1 xfailed